package fr.umlv.jee.jawp.persistence.object;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("serial")
public class Order implements Serializable {

	// members
	private int id;
	private String customer = null;
	private final Map<Product, Integer> products;
	private Status status = null;

	// constructor
	public Order() {
		super();
		this.products = new HashMap<Product, Integer>();
	}
	
	// getter and setter
	
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}

	public String getCustomer() {
		return customer;
	}

	public void setCustomer(String customer) {
		this.customer = customer;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Map<Product, Integer> getProducts() {
		return products;
	}
	
	// generic methods

	@Override
	public String toString() {
		return "Order number "+id+" for "+customer+". Satus : "+status.getName();
	}

	@Override
	public boolean equals(Object obj) {
		if( (obj instanceof Order) && (this.id == ((Order)obj).id))
			return true;
		return false;
	}
}
